/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

$(document).ready(function(){
    
    $("#txtSearch").keyup(function () {
    if ($(this).val().length > 0)
    {

        $form = $("#searchform");

        $("#loading").hide('fast').html("<div class='loading'><img src='" + base_url+('/public/images/loader.gif') + "'/></div>");

        var request = $.ajax({
            url: site_url + '/website/search/index',
            type: "POST",
            data: $form.serialize()
        })// end ajax
            .done(function (response, textStatus, jqXHR) {

                console.log("Done");

                $("#search-result").hide().html(response).fadeIn('slow');

            })// end done
            .fail(function (response, textStatus, jqXHR) {
                alert("error");
            });// end fail

        event.preventDefault();
    }// end if

    else {
        $("#search-result").html('');
    }
    $("body").click(function () {
        //alert("clicked");
        $("#search-result").html("");
    });// end click

}); // end keyup    
});// end ready


